<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>  
<!DOCTYPE html>
<html>
<head>
<title>组织机构</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<jsp:include page="/WEB-INF/views/include/newhead.jsp" />
<%@include file="/WEB-INF/views/include/treeview.jsp"%>

</head>
<body>

<body class="childrenBody site-block">
	<header class="larry-personal-tit">
		<span><c:if test="${empty office.id}">新增</c:if><c:if test="${not empty office.id}">修改</c:if>
		</span>
	</header><!-- /header -->
	
	<div class="mainCon">
      <form:form autocomplete="off" id="inputForm" modelAttribute="office" action="${ctx}/sys/office/save" method="post" >
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		
	    <div class="layui-form-item">
			<label class="layui-form-label">上级机构</label>
			<div class="layui-input-inline layui-input-inline-one">
				<sys:treeselect id="office" name="parent.id" value="${office.parent.id}" 
					labelName="parent.name" labelValue="${office.parent.name}" title="机构" 
					url="/sys/office/treeData?isReadCache=false" cssClass="layui-input layui-input-treeselect" 
				allowClear="${office.currentUser.admin}" dataMsgRequired="必填信息" />
			</div>
		</div>
		
		<div class="layui-form-item">
		    <div class="layui-inline">
		      <label class="layui-form-label"><font color="red">*</font>机构代码</label>
		      <div class="layui-input-inline">
		       <input type="hidden" name="codeOld" value="${office.code}"/> 
				  <input class="layui-input number required" name="code" value="${office.code}"  placeholder="请输入机构代码" type="text">
		      </div>
		    </div>
		    <div class="layui-inline">
		      <label class="layui-form-label"><font color="red">*</font>机构名称</label>
		      <div class="layui-input-inline">
                <input class="layui-input required" name="name" value="${office.name}"  placeholder="请输入机构名称" type="text">		      </div>
		    </div>
		</div>
		
		<div class="layui-form-item">
			    <div class="layui-inline">
			      <label class="layui-form-label"><font color="red">*</font>机构类型</label>
			      <div class="layui-input-inline">
			         <form:select path="type" cssClass="select2_ " >
			            <form:options items="${fns:getDictList('sys_office_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					 </form:select> 
			      </div>
			    </div>
			    
			   <div class="layui-inline">
			      <label class="layui-form-label">排序</label>
			      <div class="layui-input-inline">
			         <input class="layui-input number" name="doSort" value="${office.doSort}"  placeholder="请输入排序" type="text">
			      </div>
			    </div>
	     </div>
	     
		<div class="layui-form-item">
		  <div class="layui-inline">
		    <label class="layui-form-label">机构地址</label>
		    <div class="layui-input-inline layui-input-inline-one">
	           <input class="layui-input" name="address" value="${office.address}"  placeholder="请输入机构地址" type="text">
		    </div>
		   </div>
		 </div>
		
        <div class="layui-form-item">
           <div  class="layui-inline">
			<label class="layui-form-label">备注</label>
			<div class="layui-inline layui-input-inline-one">
			    <form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="200"  class="layui-textarea"/>
			</div>
			</div>
		</div>
		
		<!-- 组织级别 -->
		<input type="hidden" name="grade" value="2" />
		<!-- 是否可用 -->
		<form:select path="useable" class="form-control" cssStyle="display:none">
				<form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
		</form:select>					

		<div class="layui-form-item bottom_xf">
			<div class="layui-input-block input500">
			    <button type="button" class="layui-btn layui-btn-primary" onclick="gotoView('${ctx}/sys/office/list')">返回</button>
				<button class="layui-btn" type="submit">保存</button>
				<button onclick="formReset();" type="button"  class="layui-btn layui-btn-danger">重置</button>
		    </div>
		</div>
	</form:form>
    </div>

	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						console.log(element.parent().parent());
						error.appendTo(element.parent().parent());
					} else {
						console.log(element);
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
		
	<jsp:include page="/WEB-INF/views/include/pageJs.jsp" />
</body>
</html>
